<%@ page language="java" %>

<%@ page import="java.util.List,
                java.util.ArrayList,
                java.util.HashMap,
                java.util.Iterator,
                com.scalar.chiptrack.commons.Address,
                com.scalar.chiptrack.commons.Constants,
                com.scalar.chiptrack.commons.SessionKeys,
                com.scalar.chiptrack.users.User,
                com.scalar.chiptrack.users.Functionality,
                com.scalar.chiptrack.sales.LineItem,
                com.scalar.chiptrack.users.dao.UserDAO,
                com.scalar.chiptrack.operations.packingslip.forms.PackingSlipForm,
                com.scalar.chiptrack.operations.packingslip.CustomerShippingLineItem,
                com.scalar.chiptrack.operations.packingslip.CustomerShippingLotNumberData,
                com.scalar.chiptrack.operations.packingslip.FinalInventoryData,
                com.scalar.chiptrack.operations.packingslip.forms.PackingSlipForm,
                com.scalar.chiptrack.operations.packingslip.dao.FinalInventoryDAO,
                com.scalar.chiptrack.operations.packingslip.dao.PackingSlipDAO,
                com.scalar.chiptrack.utils.ConfigManager,
                com.scalar.chiptrack.utils.StringUtils"%>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/dropShipmentPS.do"/>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<% User user1 = (User)session.getAttribute (SessionKeys.USER_KEY); %>

<%
    PackingSlipForm packingSlipFrom = (PackingSlipForm) request.getAttribute ("packingSlipForm");

    String custShippingId = request.getParameter("customerShippingId");
    int custShippingIdValue = -1;
    try {
        custShippingIdValue = Integer.parseInt( custShippingId );
    }
    catch( NumberFormatException nfe )
    {
        // no or invalid customerShippingID
    }

    if( custShippingIdValue == -1 )
    {
        custShippingId = packingSlipFrom.getCustomerShippingId()+"";
    }

    int salesOrderId = packingSlipFrom.getSalesOrderId();

    String noOfBoxes = "";
    String tracking = "";
    String shippedVia = "";
    String weight = "";
    String contactPerson = "";
    String invoiceNo ="";
    String shippedDate = "";
    if ( request.getParameter("noOfBoxes") !=null )
    {
        noOfBoxes = request.getParameter("noOfBoxes");
    }
    else
    {
            noOfBoxes = packingSlipFrom.getNoOfBoxes();
    }
    if ( request.getParameter("tracking") !=null )
    {
        tracking = StringUtils.concatStrings( request.getParameterValues( "tracking" ), ";" );
    }
    else
    {
        tracking = packingSlipFrom.getTrackingAsString();
    }
    if ( request.getParameter("shippedVia") !=null )
    {
        shippedVia = request.getParameter("shippedVia");
    }
    else
    {
            shippedVia = packingSlipFrom.getShippedVia();
    }
    if ( request.getParameter("weight") !=null )
    {
        weight = request.getParameter("weight");
		try
		{
			if ( weight.trim().length() > 0 )
			{
				weight = StringUtils.formatAmount((float)(new Double(weight.trim()).doubleValue()), null);
			}
			else
			{
				weight = "";
			}
		}
		catch (Exception e)
		{
			weight = "";
		}
    }
    else
    {
		try
		{
			if ( packingSlipFrom.getWeight().trim().length() > 0 )
			{
				weight = StringUtils.formatAmount((float)(new Double(packingSlipFrom.getWeight().trim()).doubleValue()), null);
			}
			else
			{
				weight = "";
			}
		}
		catch (Exception e)
		{
			weight = "";
		}
    }
    if ( request.getParameter("shippedDate") !=null )
    {
        shippedDate = request.getParameter("shippedDate");
    }
    else
    {
            shippedDate = packingSlipFrom.getShipDate();
    }
    if ( request.getParameter("invNo") !=null )
    {
        invoiceNo = request.getParameter("invNo");
    }
    else
    {
            invoiceNo = packingSlipFrom.getInvNo();
    }
    if ( request.getParameter("contactPerson") !=null )
    {
        contactPerson = request.getParameter("contactPerson");
    }
    else
    {
		contactPerson = packingSlipFrom.getContactPerson();
    }


    //System.out.println(" customerShippingId "+ custShippingId + " noOfBoxes: " + noOfBoxes + " tracking: " +tracking );
%>
<html:html locale="true">

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<style type="text/css">
a { text-decoration : none}
@page {
  size: landscape;
}
}


</style>

<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type='text/css' rel='stylesheet'>
</HEAD>
<BODY bgColor='#ffffff' leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<SCRIPT language="JavaScript">
function packingSlipMenu() {
    formAction = "<%=chipTracContext%>/packingSlipMenu.do"
    document.packingSlipForm.action=formAction;
    document.packingSlipForm.submit();
}
function sendMail ()
{
    newWindow = window.open ('<%=chipTracContext%>/sendMail.do?customerShippingId=<%=custShippingId%>&salesOrderId=<%=salesOrderId%>','sendMailPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=800,height=550,resizable=yes');
    newWindow.focus();
}

function cancelPackingSlip() {
    document.packingSlipForm.action='<%=chipTracContext%>/dropShipmentPS.do?action=cancelPackingSlip';
    document.packingSlipForm.submit();
}

function confirmPackingSlip() {
    document.packingSlipForm.action='<%=chipTracContext%>/dropShipmentPS.do?action=confirmPackingSlip';
    document.packingSlipForm.submit();
}
</SCRIPT>

<!--
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TR><td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<TD bgcolor="#ffffff">
<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">

<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>
-->
<!-- body starts -->

<!--IMG src="<%=chipTracContext%>/jsp/includes/images/scalar_logo.jpg" width=180 height=72 border=0-->

<%
    boolean updatedPackingSlipView = ("yes".equalsIgnoreCase ((String) request.getAttribute ("UPDATE_PACKING_SLIP")));
    boolean savedPackingSlipView = ("yes".equalsIgnoreCase ((String) request.getAttribute ("SAVE_PACKING_SLIP")));
    boolean showMainMenu = Boolean.valueOf((String)request.getAttribute ("showMainMenu")).booleanValue();

    String showCancelButton = (String) request.getAttribute ("cancelPackingSlip");
    String showConfirmButton = (String) request.getAttribute ("confirmPackingSlip");

    boolean cancelledPackingSlip = false;
    boolean confirmedPackingSlip = false;
    boolean issuedPackingSlip = false;

    String backgroundImage = "";

    if (packingSlipFrom != null) {
        if (Constants.CUSTOMER_SHIPPING_STATUS_CANCELLED.equalsIgnoreCase (packingSlipFrom.getStatus())) {
            cancelledPackingSlip = true;
            backgroundImage = chipTracContext+"/jsp/includes/images/cancelled_icon.gif";
        }
        else if (Constants.CUSTOMER_SHIPPING_STATUS_SHIPPED.equalsIgnoreCase (packingSlipFrom.getStatus())) {
            confirmedPackingSlip = true;
        }
        else {
            issuedPackingSlip = true;
        }
    }
%>


<html:form name="packingSlipForm" type="com.scalar.chiptrack.operations.packingslip.forms.PackingSlipForm" action="/packingSlip.do?action=save">

   <table border="0" width="90%" align="center"  background='<%=backgroundImage%>'>

      <!--Bhaskar added this scriptlet on  24 july 2003-->
    <% if ( !user1.isActionAllowed ( Functionality.PACKING_SLIP, User.USER_ACTION_MODIFY ) ) { %>
            <logic:equal name="showNoModifyMessage" value="TRUE">
            <tr><td colspan='5'><font class='NArialS'><font color='blue'><b><%=Constants.NO_MODIFY_RIGHTS %></b>
            </font><TD><TR>
            </logic:equal>
        <% } %>

    <tr><td colspan=4 align=right>        
        <!--
        [<a href="javascript:window.print();" onMouseOver="window.status='Click here to print this Packing Slip';return true" onMouseOut="window.status='';return true">Print</a>]&nbsp;&nbsp;
        -->
        <font class='NArialL'>
        <%if (showMainMenu == true) {%>
        [<a href="<%=chipTracContext%>/searchPackingSlip.do" onMouseOver="window.status='Click here to go to Packingslip Main Menu';return true" onMouseOut="window.status='';return true">Packingslip Main Menu</a>]&nbsp;&nbsp;
        <%}%>
        <%if ((updatedPackingSlipView == false) && (savedPackingSlipView == false)) {%>
        <!--
        [<a href="javascript:window.close();" onMouseOver="window.status='Click here to close this window';return true" onMouseOut="window.status='';return true">Close</a>]
        -->
        <%}%>
        </font>
    </td>

    </tr>


        <%
            if ("yes".equalsIgnoreCase (showCancelButton)) {
        %>
                <tr><td colspan='4'>
                    <font class='NArialL'><font color='red'>Are you sure, you want to cancel this packing slip &nbsp;&nbsp;</font></font>
                    <!--a href="javascript:cancelPackingSlip();" onMouseOver="window.status='Confirm This Packing Slip';return true" onMouseOut="window.status='';return true">
                    <img src='< %=chipTracContext%>/jsp/includes/images/cancel.gif' height='16' width='53' border='0'></a-->
                        <chiptrack:restrictedLink functionality='<%=Functionality.PACKING_SLIP%>' action='<%=User.USER_ACTION_MODIFY%>' href='javascript:cancelPackingSlip();' onmouseover="window.status='Cancel this packing slip';return true" onmouseout="window.status='';return true"><img src='<%=chipTracContext%>/jsp/includes/images/cancel.gif' height='16' width='53' border='0'></chiptrack:restrictedLink>					
                        &nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="<%=chipTracContext%>/packingSlipMenu.do?action=view&customerShippingId=<%=custShippingId%>&noOfBoxes=<%=noOfBoxes%>&tracking=<%=tracking%>&shippedVia=<%=shippedVia%>&shipDate=<%=shippedDate%>&weight=<%=weight%>&invNo=<%=invoiceNo%>&contactPerson=<%=contactPerson%>" onMouseOver="window.status='Go Back to Main Packing Slip Menu';return true" onMouseOut="window.status='';return true">
                    <img src='<%=chipTracContext%>/jsp/includes/images/back.gif' height='16' width='39' border='0'></a>
                </td></tr>

                <tr><td colspan='6'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></td></tr>

        <%
            }
            else if ("yes".equalsIgnoreCase(showConfirmButton)) {
        %>
                <tr><td colspan='4'>
                    <font class='NArialL'><font color='red'>Are you sure, you want to confirm this packing slip &nbsp;&nbsp;</font></font>
                    <!--a href="javascript:confirmPackingSlip();" onMouseOver="window.status='Cancel This Packing Slip';return true" onMouseOut="window.status='';return true">
                    <img src='< % =chipTracContext%>/jsp/includes/images/confirm.gif' height='16' width='75' border='0'></a-->
					<!--Bhaskar added this restricted link-->
					<chiptrack:restrictedLink functionality='<%=Functionality.PACKING_SLIP%>' action='<%=User.USER_ACTION_MODIFY%>' href='javascript:confirmPackingSlip();' onmouseover="window.status='Confirm this packing slip';return true" onmouseout="window.status='';return true"><img src='<%=chipTracContext%>/jsp/includes/images/confirm.gif' height='16' width='75' border='0'></chiptrack:restrictedLink>
					&nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="<%=chipTracContext%>/packingSlipMenu.do?action=view&customerShippingId=<%=custShippingId%>&noOfBoxes=<%=noOfBoxes%>&tracking=<%=tracking%>&shippedVia=<%=shippedVia%>&shipDate=<%=shippedDate%>&weight=<%=weight%>&invNo=<%=invoiceNo%>&contactPerson=<%=contactPerson%>" onMouseOver="window.status='Go Back to Main Packing Slip Menu';return true" onMouseOut="window.status='';return true">
                    <img src='<%=chipTracContext%>/jsp/includes/images/back.gif' height='16' width='39' border='0'></a>
                </td></tr>

                <tr><td colspan='4'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></td></tr>
        <%
            }
        %>


    <tr>
        <td width="30%" align="center"><img src="<%=chipTracContext%>/jsp/includes/images/scalar_logo.jpg" height="120" width="200" border=0></td>
      <!-- <td width='1%'>&nbsp;</td>  -->
        <td width="35%"  align="center" class="NArialL"><font class='NArialW'>Drop Shipment Packing Slip</font><br><%=ConfigManager.getClientAddressLine1()%><br><%=ConfigManager.getClientAddressLine2()%><br><%=ConfigManager.getClientAddressLine3()%><br><%=ConfigManager.getClientPhone()%><br><%=ConfigManager.getClientFax()%></td>
        <!--  <td width='1%'>&nbsp;</td> -->
        <td width="20%" ><table width='50'align=center background='<%=chipTracContext%>/jsp/includes/images/printer_icon_small.gif'><tr><td>
        <a href="javascript:window.print();" title='Click here to print the Packing Slip'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></td></tr></table>
        </td>
        <td width="15%"><table border ="0"  background='<%=chipTracContext%>/jsp/includes/images/email1.gif'><tr><td>
        <a href="javascript:sendMail();" title='Click here to send mail'>&nbsp;&nbsp;&nbsp;&nbsp;</a></td></tr></table>
        </td>

   </tr>

    <%
        Address shippingAddress = packingSlipFrom.getShippingAddressObject();
        if (shippingAddress == null) {
            shippingAddress = UserDAO.loadAddressById (packingSlipFrom.getShippingToAddressId());
        }
    %>
    <tr><td colspan='4'>
        <table width="100%" border=0 cellspacing=0 cellpadding=0>
        <tr>
        <td bgcolor='#FFFFEE' class="NArialRS" align="left" width="40%">
            <table width="100%" class="NArialRS" border='1' bordercolor='#000000' cellspacing='0'>
                <tr height=30><td class="NArialR" bgcolor="#DEE1E2" >Ship From:</td></tr>
                <tr><td class="NArialRS">
                <%=ConfigManager.getClientAddressLine1()%><br>
                <%=ConfigManager.getClientAddressLine2()%><br>
                <%=ConfigManager.getClientAddressLine3()%><br><br><br>
                <%=ConfigManager.getClientPhone()%><br>
                <%=ConfigManager.getClientFax()%>
                </td></tr>
            </table>
        </td>
        <td width="20%"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td>
        <td bgcolor='#FFFFEE' class="NArialRS" align ="right"  width="40%">
            <table width="100%" class="NArialRS" border='1' bordercolor='#000000' cellspacing='0'>
                <tr height=30><td class="NArialR" bgcolor="#DEE1E2" >Ship To:</td></tr>
                <tr><td class="NArialRS">
                <bean:write name="packingSlipForm" property="customerName"/><br>
                <!--// changed by hareesh on 5th July 2003 -->
                <!--// -- START -->
                <%=(((shippingAddress.getAddress1() == null) || ((shippingAddress.getAddress1().trim().length() == 0))) ? "" : shippingAddress.getAddress1()+"<br>")%>
                <%=(((shippingAddress.getAddress2() == null) || ((shippingAddress.getAddress2().trim().length() == 0))) ? "" : shippingAddress.getAddress2()+"<br>")%>
                <%=(((shippingAddress.getCity() == null)|| (shippingAddress.getCity().trim().length()==0 )) ? "" : shippingAddress.getCity()) %>
                <% if ( ((shippingAddress.getCity() != null)&& (shippingAddress.getCity().trim().length()!=0 )) && ((shippingAddress.getState() != null)&&(shippingAddress.getState().trim().length()!=0 )))
                  { %> , <% } %>
                <%=(((shippingAddress.getState() == null)||(shippingAddress.getState().trim().length()==0 )) ? "" : shippingAddress.getState())%>
                <% if ( ((shippingAddress.getCountry() != null)&& (shippingAddress.getCountry().trim().length()!=0 )) && ((shippingAddress.getState() != null)&&(shippingAddress.getState().trim().length()!=0 )))
                  { %> , <% } %>
                <%=(((shippingAddress.getCountry() == null)||(shippingAddress.getCountry().trim().length()==0 )) ? "" : shippingAddress.getCountry())%>
                <% if ( ((shippingAddress.getCountry() != null)&& (shippingAddress.getCountry().trim().length()!=0 )) && ((shippingAddress.getZipCode() != null)&&(shippingAddress.getZipCode().trim().length()!=0 )))
                  { %> - <% } %>
                <%=(((shippingAddress.getZipCode() == null)||(shippingAddress.getZipCode().trim().length()==0)) ? "" :shippingAddress.getZipCode())%><br><br>
                Ph. <%=((shippingAddress.getPhoneNumber() == null) ? "&nbsp;" : shippingAddress.getPhoneNumber())%><br>
                Fax. <%=((shippingAddress.getFaxNumber() == null) ? "&nbsp;" : shippingAddress.getFaxNumber())%></td></tr>
                <!--// -- END -->
            </table>
        </td>
       </tr>
       </table>
      </td></tr>

        <tr><td colspan='4'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr>
        <!--tr>
            <td width="21%"><font class="NArialL">PackingSlip Label:</font></td>
            <td width="21%"><font class="NArialL"><font class="NArialL"><bean:write name="packingSlipForm" property="label"/></font></td>

            <td width="3%">&nbsp;</td>

            <td width="21%">&nbsp;</td>
            <td width="21%">&nbsp;</td>
            <td width="3%">&nbsp;</td>
        </tr-->

        <html:hidden name='packingSlipForm' property='label'/>
        <html:hidden name='packingSlipForm' property='customerShippingId'/>
        <html:hidden name='packingSlipForm' property='noOfBoxes' value = '<%=noOfBoxes%>'/>
        <html:hidden name='packingSlipForm' property='tracking' value = '<%=tracking%>'/>
        <html:hidden name='packingSlipForm' property='shippedVia' value = '<%=shippedVia%>'/>
        <html:hidden name='packingSlipForm' property='shipDate' value = '<%=shippedDate%>'/>
        <html:hidden name='packingSlipForm' property='invNo' value = '<%=invoiceNo%>'/>
        <html:hidden name='packingSlipForm' property='contactPerson' value = '<%=contactPerson%>'/>
        <html:hidden name='packingSlipForm' property='weight' value = '<%=new String().valueOf(weight)%>'/>
        <!--tr>
            <td width="21%"><font class="NArialL">Customer PO:</font></td>
            <td width="21%"><font class="NArialL"><bean:write name="packingSlipForm"  property="customerPO" /></font></td>
            <td width="3%">&nbsp;</td>

            <td width="21%"><font class="NArialL">Customer Name:</font></td>
            <td width="21%"><font class="NArialL"><bean:write name="packingSlipForm"  property="customerName" /></font></td>
            <td width="3%">&nbsp;</td>
        </tr>

        <tr>
            <td width="21%"><font class="NArialL">Shipping Contact Person:</font></td>
            <td width="21%"><font class="NArialL"><bean:write name="packingSlipForm"  property="contactPerson" /></font></td>
            <td width="3%">&nbsp;</td>

            <td width="21%"><font class="NArialL">Rep Office:</font></td>
            <td width="21%"><font class="NArialL"><bean:write name="packingSlipForm"  property="repOffice" /></font></td>
            <td width="3%">&nbsp;</td>
        </tr>

        <tr>
            <td width="21%"><font class="NArialL">Terms:</font></td>
            <td width="21%"><font class="NArialL"><bean:write name="packingSlipForm"  property="terms" /></font></td>
            <td width="3%">&nbsp;</td>

            <td width="21%"><font class="NArialL">FOB:</font></td>
            <td width="21%"><font class="NArialL"><bean:write name="packingSlipForm"  property="fob" /></font></td>
            <td width="3%">&nbsp;</td>
        </tr>

        <tr>
            <td width="21%"><font class="NArialL">No. Of Boxes:</font></td>
            <td width="21%"><font class="NArialL"><bean:write name="packingSlipForm"  property="noOfBoxes" /></font></td>
            <td width="3%">&nbsp;</td>

            <td width="21%"><font class="NArialL">Freight Tracking No:</font></td>
            <td width="21%"><font class="NArialL"><bean:write name="packingSlipForm"  property="tracking" /></font></td>
            <td width="3%">&nbsp;</td>
        </tr>

        <tr>
            <td width="21%"><font class="NArialL">Shipped VIA:</font></td>
            <td width="21%"><font class="NArialL"><bean:write name="packingSlipForm"  property="shippedVia" /></font></td>
            <td width="3%">&nbsp;</td>
        </tr>

        <tr>
            <td width="21%"><font class="NArialL">Billing Address:</font></td>
            <td width="21%"><font class="NArialL"><bean:write name="packingSlipForm"  property="billingAddress" /></font></td>
            <td width="3%">&nbsp;</td>

            <td width="21%"><font class="NArialL">Shipping Address:</font></td>
            <td width="21%"><font class="NArialL"><bean:write name="packingSlipForm"  property="shippingAddress" /></font></td>
            <td width="3%">&nbsp;</td>
        </tr-->

        <tr><td colspan=4><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>

        <tr><td colspan=4 width="100%">
            <table border='1' width="100%" class='NArialRS' bordercolor='#000000' cellspacing='0'>

                <tr>
                    <td width='12%' align='center' bgcolor='#DEE1E2' class='NArialR'>Customer PO#</td>
                    <td width='12%' align='center' bgcolor='#DEE1E2' class='NArialR'>Sales Order#</td>
                    <td width='12%' align='center' bgcolor='#DEE1E2' class='NArialR'>Actual Ship Date</td>
                    <td width='15%' align='center' bgcolor='#DEE1E2' class='NArialR'>Shipped Via</td>
                    <!--td width='12%' align='center' bgcolor='#DEE1E2'>Freight Tracking</td-->
                    <td width='12%' align='center' bgcolor='#DEE1E2' class='NArialR'>Del. Terms</td>
                    <td width='4%' align='center' bgcolor='#DEE1E2' class='NArialR'># Cartons</td>
                    <td width='12%' align='center' bgcolor='#DEE1E2' class='NArialR'>Weight<br>(Lbs)</td>
                </tr>

                <tr>
                    <td width='12%' align='center' bgcolor='#FFFFEE'><bean:write name="packingSlipForm"  property="customerPO" /></td>
                    <td width='12%' align='center' bgcolor='#FFFFEE'><bean:write name="packingSlipForm"  property="salesOrderNumber" /></td>
                    <td width='12%' align='center'  bgcolor='#FFFFEE'><%=( (shippedDate.equals("null")) ||(shippedDate.equals(""))? "&nbsp; " :shippedDate )%>
                                                            <!--bean:write name="packingSlipForm"  property="shipDate" /--></td>
                    <td width='15%' align='center' bgcolor='#FFFFEE'> <%=( (shippedVia == null ) || (shippedVia.trim().length() == 0) || (shippedVia.equals("null") )? "&nbsp; " :shippedVia )%>
                                                        <!--bean:write name="packingSlipForm"  property="shippedVia" /-->&nbsp;</td>
                   <!--td width='12%' bgcolor='#FFFFEE' align='right'><bean:write name="packingSlipForm"  property="tracking" /></td-->
                    <td width='12%' align='center' bgcolor='#FFFFEE'>&nbsp;<bean:write name="packingSlipForm"  property="termsForHtmlView" /></td>
                    <td width='4%' align='right'  bgcolor='#FFFFEE'>&nbsp;<%=((noOfBoxes.equals("0")) ||(noOfBoxes.equals(""))? "&nbsp; " :noOfBoxes )%></td>
                    <td width='12%' align='right' bgcolor='#FFFFEE'><%=weight%>&nbsp;</td>
                                    <!--bean:write name="packingSlipForm"  property="weight" /--></td>
                </tr>

            </table>
        </td></tr>

        <tr><td colspan=4><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>


        <tr><td colspan=4><font class="NArialR"><strong><u>Shipping Instructions:</u></strong></font></td></tr>

        <tr><td colspan=4 bgcolor='#DEE1E2' width="100%"><font class="NArialRS"><bean:write name="packingSlipForm"  property="shippingInstructions" /></font></td></tr>

        <tr><td colspan=4><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>

        <tr><td colspan=4 width="100%">
            <table border="1" width="100%" align='center' bordercolor='#000000' cellspacing='0' cellpadding='0'>
                <tr>
	                <td width="5%" nowrap align="center" bgcolor="#DEE1E2"><font class="NArialR">PO Line<br>Item</font></td>
                    <% if (ConfigManager.getBooleanProperty(ConfigManager.SHOW_MFG_PARTNO_PACKINGSLIP ) ) { %>
                    <td width="10%" nowrap align="center" bgcolor="#DEE1E2"><font class="NArialR">
					<bean:message key = "label.mfgPartNumber" /></font></td>
                    <%  } if (ConfigManager.getBooleanProperty(ConfigManager.SHOW_MRKT_PARTNO_PACKINGSLIP ) ) { %>
                    <td width="10%" nowrap align="center" bgcolor="#DEE1E2"><font class="NArialR">
					<bean:message key = "label.mktgPartNumber" /></font></td>
                    <% } %>
                    <td width="10%" nowrap align="center" bgcolor="#DEE1E2"><font class="NArialR">
					<bean:message key = "label.customerPartNumber" />
					<!-- Customer <br>Part Number --></font></td>
                    <td width="25%" nowrap align="center" bgcolor="#DEE1E2"><font class="NArialR">Description</font></td>
                    <td width="5%" nowrap align="center" bgcolor="#DEE1E2"><font class="NArialR">Unit Type</font></td>
                    <td width="10%" nowrap align="center" bgcolor="#DEE1E2"><font class="NArialR">Request Date</font></td>
                    <td width="10%" nowrap align="center" bgcolor="#DEE1E2"><font class="NArialR">Schedule Date</font></td>
                    <td width="10%" nowrap align="center" bgcolor="#DEE1E2"><font class="NArialR">Req Qty</font></td>
                    <td width="10%" nowrap align="center" bgcolor="#DEE1E2"><font class="NArialR">Qty <br>Shipped</font></td>
                    <td width="15%" nowrap align="center" bgcolor="#DEE1E2" nowrap><font class="NArialR">Lot # Vs Qty</font></td>
                </tr>

            <%
                int customerShippingId = packingSlipFrom.getCustomerShippingId();

                List orderLineItemList = (List) request.getAttribute ("orderLineItemList");
                if (orderLineItemList == null) orderLineItemList = new ArrayList();

                HashMap csLineItemMap = (HashMap) request.getAttribute ("customerShippingLineItemMap");
                if (csLineItemMap == null) csLineItemMap = new HashMap();

                LineItem lineItem = null;
                CustomerShippingLineItem csLineItem = null;
                FinalInventoryData finalInventoryData = null;
                int size = orderLineItemList.size();

                HashMap customerShippingLotNumberMap = null;
                Iterator customerShippingLotNumbers = null;
                CustomerShippingLotNumberData customerShippingLotNumberData = null;

                //for (int i=(size-1); i>=0; i--) {
                 for (int i=0; i <= (size-1); i++) { // changed by hareesh on 9th July 2003
                    lineItem = (LineItem) orderLineItemList.get (i);
                    csLineItem = (CustomerShippingLineItem) csLineItemMap.get (lineItem.getLineItemId()+"");

                    //Added by vasu on 22 May 2003
                     String description = null;

                    if( csLineItem != null )
                    {
                        description = csLineItem.getDescription();
                    }

                    // Balaram, June 23, 2003
                    if( ( ( description == null ) || ( description.trim().length() == 0 ) ) && ( lineItem != null ) )
                    {
                        description = lineItem.getDescription();
                    }

                    if( ( description == null ) || ( description.equalsIgnoreCase( "null" ) ) )
                    {
                        description = "&nbsp;";
                    }

					//Bhaskar added this units block on 28 Jan 2004
					String units = null;
					if(csLineItem != null)
					units = csLineItem.getUnits();
					if((units == null) || ((units != null) && (units.equalsIgnoreCase("null"))))
					units = "&nbsp;";

					//Added  by Bhaskar for customerPartNumber  on 28 Jan 2004
                      String customerPartNumber = null;
                    if(csLineItem != null)
                        customerPartNumber = csLineItem.getCustomerPartNumber();
                    if((customerPartNumber == null) || ((customerPartNumber != null) && (customerPartNumber.equalsIgnoreCase("null"))))
                        customerPartNumber = "";

                        //String shippedDate = null;
                        // changed by hareesh on 4th July 2003
                        // -- START --
                        /*if (csLineItem != null)
                        {
                            shippedDate = csLineItem.getShippedDate();
                        }
                        if ( ( shippedDate == null ) || (shippedDate.trim().length()==0))
                        {
                            shippedDate = lineItem.getScheduleDate();
                        } */
                        shippedDate = lineItem.getScheduleDate();
                        // -- END --

                    %>
                    <!--td width="10%" align="center" bgcolor="#FFFFEE"><font class="NArialL"><%=shippedDate%></font></td-->
                <tr>                    
					<td width="5%" align="center" bgcolor="#FFFFEE"><font class="NArialRS">
						<% if( lineItem.getPoLineItemNo() == 0  ) {%>
							&nbsp;
						<%} else {%>
							<%=lineItem.getPoLineItemNo()%>
						<%}%>
					</font></td>
                    <% if (ConfigManager.getBooleanProperty(ConfigManager.SHOW_MFG_PARTNO_PACKINGSLIP ) ) { %>
                    <td width="10%" nowrap align="left" bgcolor="#FFFFEE"><font class="NArialRS"><%=lineItem.getManufacturingPartNo()%></font></td>
                    <%  } if (ConfigManager.getBooleanProperty(ConfigManager.SHOW_MRKT_PARTNO_PACKINGSLIP ) ) { %>
                    <td width="10%" nowrap align="left" bgcolor="#FFFFEE"><font class="NArialRS"><%=lineItem.getMarketingPartNo()%></font></td>
                    <% } %>
                    <td width="10%" nowrap align="left" bgcolor="#FFFFEE"><font class="NArialRS">
					<%= customerPartNumber%>&nbsp;</font></td>
                    <!--
                    <td width="100" align="center" bgcolor="#FFFFEE"><font class="NArialR"><%=description%></font></td>
                    -->
                    <td width="25%" align="left" bgcolor="#FFFFEE">
                    <table border="0" width="90" bgcolor="#FFFFEE" class="viewTable"><tr><td align="left" bgcolor="#FFFFEE"><font class="NArialRS"><%=description%></font></td></tr></table>
                    </td>
                    <td width="5%" nowrap align="left" bgcolor="#FFFFEE"><font class="NArialRS"><%= units%>&nbsp;</font></td>
                    <td width="10%" align="center" bgcolor="#FFFFEE">
					<font class="NArialRS"><%=(lineItem.getRequestDate()!=null?lineItem.getRequestDate():"&nbsp")%>&nbsp;</font></td>
                    <td width="10%" align="center" bgcolor="#FFFFEE"><font class="NArialRS"><%=(shippedDate !=null)?shippedDate:"&nbsp;"%>&nbsp;</font></td>
                    <td width="10%" align="right" bgcolor="#FFFFEE"><font class="NArialRS"><%if (lineItem != null) out.print (StringUtils.formatUnits (lineItem.getQuantity()));%>&nbsp;&nbsp;</font></td>
                    <td width="10%" align="right" bgcolor="#FFFFEE"><font class="NArialRS"><%if (csLineItem != null) out.print (StringUtils.formatUnits (csLineItem.getQtyShipped()));%>&nbsp;&nbsp;</font></td>





                    <td width="15%" align="left" bgcolor="#FFFFEE" nowrap><font class="NArialRS">
                    <table border='1' bordercolor='gray' cellspacing='0'  cellpadding='0' width='100%' >
                    <%
                        String lotNumbers = "";

                        customerShippingLotNumberMap = PackingSlipDAO.loadCustomerShippingLotNumberData (customerShippingId, lineItem.getLineItemId());
                        customerShippingLotNumbers = customerShippingLotNumberMap.values().iterator();

                        int qtyPull = 0;
                        while (customerShippingLotNumbers.hasNext()) {
                            customerShippingLotNumberData = (CustomerShippingLotNumberData) customerShippingLotNumbers.next();
                            qtyPull = customerShippingLotNumberData.getQtyPull();

                            if (qtyPull > 0) {
                    %>
                                <tr>
                                <td nowrap><font class='NArialRS'><%=customerShippingLotNumberData.getLotNumber()%></font></td>
                                <td nowrap><font class='NArialRS'><%=qtyPull%></font></td>
                                </tr>
                    <%
                            }
                        }
                    %>
                    </table>
                    </font></td>
                </tr>
            <%
                }   // for (int i=0; i<size; i++) {
            %>

	   </table></td></tr>

        <tr><td colspan=4><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr>
		<tr><td colspan=4>
		<table border="0" width="100%" align='center' bordercolor='#FFFFFF' cellspacing='2' cellpadding='2'>
		<tr><td align="center"><font class='NArialView'>CERTIFICATE OF COMPLIANCE</font></td></tr>
		<tr><td><font class='NArialRS'>THIS PRODUCT SHIPPED HERE WITH HAVE BEEN INSPECTED AND COMPLY WITH THE REQUIREMENTS OF YOUR PURCHASE ORDER TO THE EXTENT THAT SUCH REQUIREMENT HAVE BEEN ACCEPTED AND ACKNOWLEDGED BY CAVIUM SUBSTANTIATING INSPECTION AND TEST ON THAT FILE.</font></td></tr>
		<tr><td align="center"><font class='NArialRS'><B>THANK YOU FOR YOUR BUSINESS!</B></font></td></tr>
		</table></td></tr>
        <tr><td colspan=4><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
        <!--tr>
            <td bgcolor='silver' colspan=3 class='NArialL' valign='top' align='top' nowrap>Customer Note:</td>
            <td>&nbsp;</td>
            <td bgcolor='silver' colspan=2 class='NArialL' valign='top' align='top' nowrap>Received By:</td>
        </tr-->
        <tr>
            <td class='NArialR'>Packer: </td>
            <td colspan=2 class='NArialR'>__________________________________________ </td>
            <td >&nbsp;</td>
        </tr>
        <tr>
            <td class='NArialR'>Hand Carry Receipt: </td>
            <td colspan=2 class='NArialR'>__________________________________________ <br>Signature & Title</td>
            <td >&nbsp;</td>
        </tr>
        <tr>
            <td class='NArialR'>&nbsp;</td>
            <td colspan=2 class='NArialR'>__________________________________________ <br>Print Name & Date</td>
            <td >&nbsp;</td>
        </tr>

        <tr><td colspan=4><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=70></td></tr>
    </table>

</html:form>

<!-- till here -->
<!--
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>
-->
</body>

</html:html>
